import axios from '@/libs/axios1'
import axios_unxss from "@/libs/axios_unxss";
let jsonHeaders = {'content-type': 'application/json;charset=UTF-8'}
//添加公告
export const addBoardCast = params => {
	return axios({
		url: `/notice/notice/add`,
		method: 'post',
		data: params,
		headers: jsonHeaders
	})
}
//查询公告
export const queryBoardCast = params => {
	return axios_unxss({
		url: `/notice/notice/page`,
		method: 'get',
		params: params,
		headers: jsonHeaders
	})
}
//修改公告
export const updateBoardCast = params => {
	return axios({
		url: `/notice/notice/update/${params.id}`,
		method: 'put',
		data: params.obj,
		headers: jsonHeaders
	})
}
//删除公告
export const delBoardCast = params => {
	return axios({
		url: `/notice/notice/delete/${params}`,
		method: 'delete',
		headers: jsonHeaders
	})
}

//发送公告给场景
export const sendToSence = params => {
	return axios({
		url: `/notice/noticeMessage/sendSceneNotice/${params.sceneId}`,
		method: 'post',
		data:params.noticeSceneDto,
		headers: jsonHeaders
	})
}

//发送公告给场景
export const sendToSenceDis = params => {
	return axios({
		url: `/notice/noticeMessage/sendDistRangeSceneNotice/${params.sceneId}`,
		method: 'post',
		data:params.noticeSceneDto,
		headers: jsonHeaders
	})
}
//发送公告给用户
export const sendToUser = (params) => {
	return axios({
		url: `/notice/noticeMessage/sendNoticeByUserType`,
		method: 'post',
		data:params,
		headers: jsonHeaders
	})
}

//发送公告给用户组
export const sendToUserGroup = (params) => {
	return axios({
		url: `/notice/noticeMessage/sendNoticeByGroup`,
		method: 'post',
		data:params,
		headers: jsonHeaders
	})
}

//获取发送公告列表
export const getNoticeList = (params) => {
	return axios({
		url: `/notice/noticeMessage/page`,
		method: 'get',
		data:params,
		headers: jsonHeaders
	})
}

//清空场景公告
export const clearSceneNotice = (sceneId) => {
	return axios({
		url: `/notice/noticeMessage/clearSceneNotice/${sceneId}`,
		method: 'post',
		data:{},
		headers: jsonHeaders
	})
}

export const boardlist_new = params =>{
  return axios_unxss({
    url:`/notice/noticeMessage/page`,
    method:'get',
    params:params,
    headers:jsonHeaders
  })
}

//将公告标为已读
export const changeMsgRead = id =>{
  return axios({
    url:`/notice/noticeMessage/changeMsgRead/${id}`,
    method:'put',
    headers:jsonHeaders
  })
}


//全部标记为已读
export const setChatAllRead = ()=> {
  return axios({
    url: `/notice/noticeMessage/allRead`,
    method: 'put',
    headers: jsonHeaders
  })
}

/*********聊天*********/
//私信
export const chatSingle = (params,content) => {
  return axios({
    url: `/notice/chat/single/${params.userId}/${params.msgType}`,
    method: 'post',
    data:content,
    headers: jsonHeaders
  })
}
//群聊/chat/group/{groupType}/{groupId}{msgType}
export const chatGroup = (params,content) => {
  return axios({
    url: `/notice/chat/group/${params.groupType}/${params.groupId}/${params.msgType}`,
    method: 'post',
    data:content,
    headers: jsonHeaders
  })
}

//标记某用户聊天消息未已读
export const setChatSingleRead = (sceneId,userId) => {
  return axios({
   url: `/notice/chat/changeMsgReadedByUserId/${userId}`,
    method: 'put',
    params:{
    	sceneId
    },
    headers: jsonHeaders
  })
}


//修改当前用户群聊未读消息为已读
export const setChatGroupRead = (sceneId,groupId) => {
  return axios({
    url: `/notice/chat/changeMsgReadedByGroupId/${sceneId}/${groupId}`,
    method: 'put',
    headers: jsonHeaders
  })
}

//获取未读消息数
export const getNotReadChat = (sceneId) => {
  return axios({
    url: `/notice/chat/news`,
    method: 'GET',
    params:{
    	sceneId
    },
    headers: jsonHeaders
  })
}

//获取自定义群组与成员未读消息数
export const getClassNotReadChat = (groupId) => {
  return axios({
    url: `/notice/chat/customGroup/${groupId}/news`,
    method: 'GET',
    headers: jsonHeaders
  })
}

//获取当前用户与某用户得聊天记录
export const getNotReadChatWithUser = (sceneId,userId) => {
  return axios({
    url: `/notice/chat/${userId}`,
    method: 'GET',
    params:{
    	sceneId
    },
    headers: jsonHeaders
  })
}

//获取当前用户群聊天记录
export const getNotReadChatWithGroup = (groupId) => {
  return axios({
    url: `/notice/chat/group/${groupId}`,
    method: 'GET',
    headers: jsonHeaders
  })
}

//清空场景聊天消息
export const clearSceneChatMsg = (sceneId) => {
	return axios({
		url: `/notice/chat/clearSceneIdChatMessage/${sceneId}`,
		method: 'post',
		data:{},
		headers: jsonHeaders
	})
}
export const clearSceneNoticeAndChat = (sceneId) => {
	return axios({
		url: `/notice/noticeMessage/clearSceneNoticeAndChat/${sceneId}`,
		method: 'post',
		data:{},
		headers: jsonHeaders
	})
}
/********自定义群组 -- start*********/
//添加自定义群组
export const addGroup = data => {
  return axios({
    url: `/notice/group/addGroupAndMembers`,
    method: 'post',
    data:data,
    headers: jsonHeaders
  })
}

//删除自定义群组
export const delGroup = groupId => {
  return axios({
    url: `/notice/group/${groupId}`,
    method: 'delete',
    headers: jsonHeaders
  })
}

//添加群组成员
export const addGroupUsers = (groupId,groupUsers) => {
  return axios({
    url: `/notice/member/add/${groupId}`,
    method: 'post',
    data:groupUsers,
    headers: jsonHeaders
  })
}

//删除群组成员
export const delGroupUsers = (groupId,groupUsers) => {
  return axios({
    url: `/notice/member/${groupId}`,
    method: 'delete',
    data:groupUsers,
    headers: jsonHeaders
  })
}

//查询群组成员
export const getGroupUsers = params => {
  return axios({
    url: `/notice/member/page`,
    method: 'get',
    params:params,
    headers: jsonHeaders
  })
}

//获取群组详情
export const getGroupInfo = id => {
  return axios({
    url: `/notice/group/${id}`,
    method: 'get',
    params:{},
    headers: jsonHeaders
  })
}

/********自定义群组 -- end*********/


//编辑自定义群组
export const updateGroup = (data) => {
    return axios({
        url: `/notice/group/updateGroupAndMembers`,
        method: 'put',
        data: data,
        headers: jsonHeaders
    });
};

